package com.microinvest.controller.admin;

import com.microinvest.entity.BuyStock;
import com.microinvest.entity.SellStock;
import com.microinvest.entity.Users;
import com.microinvest.service.AdminService;
import com.microinvest.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    private final AdminService adminService;

    @Autowired
    public AdminController(AdminService adminService){
        this.adminService=adminService;
    }


    @PostMapping("/loginWithAdminNamePassword")
    public Result<String> loginWithAdminNamePassword(String AdminName, String password){
        //由前端判断输入是否为空
        Result result=adminService.loginWithAdminNamePasswordService(AdminName,password);
        return result;
    }

    @GetMapping("/getUsersMessage")
    public Result<List<Users>> getUsersMessage(){
        Result<List<Users>> result= adminService.getUsersMessageService();
        return result;

    }

    @GetMapping("/getBuyStockMessage")
    public Result<List<BuyStock>> getBuyStockMessage(){
        Result<List<BuyStock>> result= adminService.getBuyStockMessage();
        return result;

    }

    @GetMapping("/getSellStockMessage")
    public Result<List<SellStock>> getSellStockMessage(){
        Result<List<SellStock>> result= adminService.getSellStockMessage();
        return result;

    }
}
